import java.util.Scanner;

//1、字符串逆置，如 "I am a student" 逆置为 "student a am I"
//思路：先将字符串整体逆置，再一一逆置
public class Text {
    public static String reverseSentence(String str) {
        if(str==null){
            return null;
        }
         char[] ch=str.toCharArray();
         int len=str.length();
         reverse(ch,0,len-1);//先整体逆置
         int i=0,j=0;
         while(i<len){
             if(ch[i]==' '){
                 i++;
                 j++;
             }else if(j==len||ch[j]==' '){
                 //顺序不能反
                 reverse(ch,i,--j);
                 i=++j;
             }else {
                 ++j;
             }
         }
               return String.copyValueOf(ch);

    }

    public static void reverse(char[] ch,int left,int right) {
        while(left<right){
            char tmp=ch[left];
            ch[left]=ch[right];
            ch[right]=tmp;
            left++;
            right--;
        }

    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String str=sc.nextLine();
        System.out.println(reverseSentence(str));

    }

}
